package com.vincent.template.controller;

import com.vincent.template.store.AuthUriStore;
import com.vincent.template.store.UserRoleAuthStore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Vincent Wang
 * @date 2021/1/16 02:26
 */
@RestController
@RequestMapping("/cache")
public class CacheController {

    @Autowired
    private AuthUriStore authUriStore;
    @Autowired
    private UserRoleAuthStore userRoleAuthStore;

    @PostMapping("/uri/refresh")
    public void refreshUri() {
        authUriStore.refreshUris();
        authUriStore.refreshAuthUrisMap();
    }

    @PostMapping("/user/refresh")
    public void refreshUser(@RequestParam("userId") String userId) {
        userRoleAuthStore.refreshRolesAndAuths(userId);
    }
}
